class_name PlayerGroundState
extends GameplayStateMachine

@onready var player: Player = $"../../"


func _on_setup() -> void:
	var multiway_transition: GameplayMultiwayTransition = GameplayMultiwayTransition.new(
		[
			func(): return 0 if player.player_input_handler.crouch_input or player.player_state_checker.is_head_collide_detected else 1,
			func(): return 0 if player.player_input_handler.idle_input else 1 if player.player_input_handler.walk_input else 2
		],
		{
			[0, 0]: "PlayerCrouchState",
			[0, 1]: "PlayerStealthState",
			[0, 2]: "PlayerRollState",
			[1, 0]: "PlayerIdleState",
			[1, 1]: "PlayerWalkState",
			[1, 2]: "PlayerRunState"
		}
	)

	add_transition("GhostState", multiway_transition)
	add_transition("PlayerIdleState", multiway_transition)
	add_transition("PlayerWalkState", multiway_transition)
	add_transition("PlayerRunState", multiway_transition)
	add_transition("PlayerCrouchState", multiway_transition)
	add_transition("PlayerStealthState", multiway_transition)

	var normal_attack_transition: GameplaySimpleTransition = GameplaySimpleTransition.new("PlayerNormalAttackState", func(): return player.player_input_handler.normal_attack_input or player.player_input_handler.normal_attack_keep_input, func(): pass)
	add_transition("PlayerIdleState", normal_attack_transition)
	add_transition("PlayerWalkState", normal_attack_transition)
	add_transition("PlayerRunState", normal_attack_transition)
